<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Data Checksums</title>
<meta name="generator" content="DocBook XSL Stylesheets V1.73.2">
<link rel="start" href="index.html" title="GLib Reference Manual">
<link rel="up" href="glib-utilities.html" title="GLib Utilities">
<link rel="prev" href="glib-Base64-Encoding.html" title="Base64 Encoding">
<link rel="next" href="glib-I18N.html" title="Internationalization">
<meta name="generator" content="GTK-Doc V1.9 (XML mode)">
<link rel="stylesheet" href="style.css" type="text/css">
<link rel="chapter" href="glib.html" title="GLib Overview">
<link rel="chapter" href="glib-fundamentals.html" title="GLib Fundamentals">
<link rel="chapter" href="glib-core.html" title="GLib Core Application Support">
<link rel="chapter" href="glib-utilities.html" title="GLib Utilities">
<link rel="chapter" href="glib-data-types.html" title="GLib Data Types">
<link rel="chapter" href="tools.html" title="GLib Tools">
<link rel="index" href="ix01.html" title="Index">
<link rel="index" href="ix02.html" title="Index of deprecated symbols">
<link rel="index" href="ix03.html" title="Index of new symbols in 2.2">
<link rel="index" href="ix04.html" title="Index of new symbols in 2.4">
<link rel="index" href="ix05.html" title="Index of new symbols in 2.6">
<link rel="index" href="ix06.html" title="Index of new symbols in 2.8">
<link rel="index" href="ix07.html" title="Index of new symbols in 2.10">
<link rel="index" href="ix08.html" title="Index of new symbols in 2.12">
<link rel="index" href="ix09.html" title="Index of new symbols in 2.14">
<link rel="index" href="ix10.html" title="Index of new symbols in 2.16">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2">
<tr valign="middle">
<td><a accesskey="p" href="glib-Base64-Encoding.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td>
<td><a accesskey="u" href="glib-utilities.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td>
<td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td>
<th width="100%" align="center">GLib Reference Manual</th>
<td><a accesskey="n" href="glib-I18N.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td>
</tr>
<tr><td colspan="5" class="shortcuts"><nobr><a href="#id3084209" class="shortcut">Top</a>
                  &#160;|&#160;
                  <a href="#id3084511" class="shortcut">Description</a></nobr></td></tr>
</table>
<div class="refentry" lang="en">
<a name="glib-Data-Checksums"></a><div class="titlepage"></div>
<div class="refnamediv"><table width="100%"><tr>
<td valign="top">
<h2>
<a name="id3084209"></a><span class="refentrytitle">Data Checksums</span>
</h2>
<p>Data Checksums &#8212; Computes the checksum for data</p>
</td>
<td valign="top" align="right"></td>
</tr></table></div>
<div class="refsynopsisdiv">
<h2>Synopsis</h2>
<pre class="synopsis">

#include &lt;glib.h&gt;


enum                <a class="link" href="glib-Data-Checksums.html#GChecksumType">GChecksumType</a>;
<a class="link" href="glib-Basic-Types.html#gssize">gssize</a>              <a class="link" href="glib-Data-Checksums.html#g-checksum-type-get-length">g_checksum_type_get_length</a>          (<a class="link" href="glib-Data-Checksums.html#GChecksumType">GChecksumType</a> checksum_type);
                    <a class="link" href="glib-Data-Checksums.html#GChecksum">GChecksum</a>;
<a class="link" href="glib-Data-Checksums.html#GChecksum">GChecksum</a>*          <a class="link" href="glib-Data-Checksums.html#g-checksum-new">g_checksum_new</a>                      (<a class="link" href="glib-Data-Checksums.html#GChecksumType">GChecksumType</a> checksum_type);
<a class="link" href="glib-Data-Checksums.html#GChecksum">GChecksum</a>*          <a class="link" href="glib-Data-Checksums.html#g-checksum-copy">g_checksum_copy</a>                     (const <a class="link" href="glib-Data-Checksums.html#GChecksum">GChecksum</a> *checksum);
void                <a class="link" href="glib-Data-Checksums.html#g-checksum-free">g_checksum_free</a>                     (<a class="link" href="glib-Data-Checksums.html#GChecksum">GChecksum</a> *checksum);
void                <a class="link" href="glib-Data-Checksums.html#g-checksum-update">g_checksum_update</a>                   (<a class="link" href="glib-Data-Checksums.html#GChecksum">GChecksum</a> *checksum,
                                                         const <a class="link" href="glib-Basic-Types.html#guchar">guchar</a> *data,
                                                         <a class="link" href="glib-Basic-Types.html#gssize">gssize</a> length);
const <a class="link" href="glib-Basic-Types.html#gchar">gchar</a>*        <a class="link" href="glib-Data-Checksums.html#g-checksum-get-string">g_checksum_get_string</a>               (<a class="link" href="glib-Data-Checksums.html#GChecksum">GChecksum</a> *checksum);
void                <a class="link" href="glib-Data-Checksums.html#g-checksum-get-digest">g_checksum_get_digest</a>               (<a class="link" href="glib-Data-Checksums.html#GChecksum">GChecksum</a> *checksum,
                                                         <a class="link" href="glib-Basic-Types.html#guint8">guint8</a> *buffer,
                                                         <a class="link" href="glib-Basic-Types.html#gsize">gsize</a> *digest_len);

<a class="link" href="glib-Basic-Types.html#gchar">gchar</a>*              <a class="link" href="glib-Data-Checksums.html#g-compute-checksum-for-data">g_compute_checksum_for_data</a>         (<a class="link" href="glib-Data-Checksums.html#GChecksumType">GChecksumType</a> checksum_type,
                                                         const <a class="link" href="glib-Basic-Types.html#guchar">guchar</a> *data,
                                                         <a class="link" href="glib-Basic-Types.html#gsize">gsize</a> length);
<a class="link" href="glib-Basic-Types.html#gchar">gchar</a>*              <a class="link" href="glib-Data-Checksums.html#g-compute-checksum-for-string">g_compute_checksum_for_string</a>       (<a class="link" href="glib-Data-Checksums.html#GChecksumType">GChecksumType</a> checksum_type,
                                                         const <a class="link" href="glib-Basic-Types.html#gchar">gchar</a> *str,
                                                         <a class="link" href="glib-Basic-Types.html#gssize">gssize</a> length);
</pre>
</div>
<div class="refsect1" lang="en">
<a name="id3084511"></a><h2>Description</h2>
<p>
GLib provides a generic API for computing checksums (or "digests") for a
sequence of arbitrary bytes, using various hashing algorithms like MD5,
SHA-1 and SHA-256. Checksums are commonly used in various environments and
specifications.
</p>
<p>
GLib supports incremental checksums using the GChecksum data structure, by
calling <a class="link" href="glib-Data-Checksums.html#g-checksum-update"><code class="function">g_checksum_update()</code></a> as long as there's data available and then using
<a class="link" href="glib-Data-Checksums.html#g-checksum-get-string"><code class="function">g_checksum_get_string()</code></a> or <a class="link" href="glib-Data-Checksums.html#g-checksum-get-digest"><code class="function">g_checksum_get_digest()</code></a> to compute the checksum
and return it either as a string in hexadecimal form, or as a raw sequence
of bytes. To compute the checksum for binary blobs and NUL-terminated strings
in one go, use the convenience functions <a class="link" href="glib-Data-Checksums.html#g-compute-checksum-for-data"><code class="function">g_compute_checksum_for_data()</code></a> and
<a class="link" href="glib-Data-Checksums.html#g-compute-checksum-for-string"><code class="function">g_compute_checksum_for_string()</code></a>, respectively.
</p>
<p>
Support for checksums has been added in GLib 2.16
</p>
</div>
<div class="refsect1" lang="en">
<a name="id3084599"></a><h2>Details</h2>
<div class="refsect2" lang="en">
<a name="id3084609"></a><h3>
<a name="GChecksumType"></a>enum GChecksumType</h3>
<a class="indexterm" name="id3084623"></a><pre class="programlisting">typedef enum {
  G_CHECKSUM_MD5,
  G_CHECKSUM_SHA1,
  G_CHECKSUM_SHA256
} GChecksumType;
</pre>
<p>
The hashing algorithm to be used by <a class="link" href="glib-Data-Checksums.html#GChecksum"><span class="type">GChecksum</span></a> when performing the
digest of some data.
</p>
<p>
Note that the <a class="link" href="glib-Data-Checksums.html#GChecksumType"><span class="type">GChecksumType</span></a> enumeration may be extended at a later 
date to include new hashing algorithm types.</p>
<p>

</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><a name="G-CHECKSUM-MD5:CAPS"></a><code class="literal">G_CHECKSUM_MD5</code></span></p></td>
<td> Use the MD5 hashing algorithm
</td>
</tr>
<tr>
<td><p><span class="term"><a name="G-CHECKSUM-SHA1:CAPS"></a><code class="literal">G_CHECKSUM_SHA1</code></span></p></td>
<td> Use the SHA-1 hashing algorithm
</td>
</tr>
<tr>
<td><p><span class="term"><a name="G-CHECKSUM-SHA256:CAPS"></a><code class="literal">G_CHECKSUM_SHA256</code></span></p></td>
<td> Use the SHA-256 hashing algorithm
</td>
</tr>
</tbody>
</table></div>
<p class="since">Since  2.16
</p>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id3084745"></a><h3>
<a name="g-checksum-type-get-length"></a>g_checksum_type_get_length ()</h3>
<a class="indexterm" name="id3084760"></a><pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gssize">gssize</a>              g_checksum_type_get_length          (<a class="link" href="glib-Data-Checksums.html#GChecksumType">GChecksumType</a> checksum_type);</pre>
<p>
Gets the length in bytes of digests of type <em class="parameter"><code>checksum_type</code></em></p>
<p>

</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>checksum_type</code></em>&#160;:</span></p></td>
<td> a <a class="link" href="glib-Data-Checksums.html#GChecksumType"><span class="type">GChecksumType</span></a>
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></p></td>
<td> the checksum length, or -1 if <em class="parameter"><code>checksum_type</code></em> is
not supported.

</td>
</tr>
</tbody>
</table></div>
<p class="since">Since  2.16
</p>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id3084848"></a><h3>
<a name="GChecksum"></a>GChecksum</h3>
<a class="indexterm" name="id3084860"></a><pre class="programlisting">typedef struct _GChecksum GChecksum;</pre>
<p>

</p>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id3084875"></a><h3>
<a name="g-checksum-new"></a>g_checksum_new ()</h3>
<a class="indexterm" name="id3084890"></a><pre class="programlisting"><a class="link" href="glib-Data-Checksums.html#GChecksum">GChecksum</a>*          g_checksum_new                      (<a class="link" href="glib-Data-Checksums.html#GChecksumType">GChecksumType</a> checksum_type);</pre>
<p>
Creates a new <a class="link" href="glib-Data-Checksums.html#GChecksum"><span class="type">GChecksum</span></a>, using the checksum algorithm <em class="parameter"><code>checksum_type</code></em>. 
If the <em class="parameter"><code>checksum_type</code></em> is not known, <a class="link" href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> is returned.
A <a class="link" href="glib-Data-Checksums.html#GChecksum"><span class="type">GChecksum</span></a> can be used to compute the checksum, or digest, of an
arbitrary binary blob, using different hashing algorithms.
</p>
<p>
A <a class="link" href="glib-Data-Checksums.html#GChecksum"><span class="type">GChecksum</span></a> works by feeding a binary blob through <a class="link" href="glib-Data-Checksums.html#g-checksum-update"><code class="function">g_checksum_update()</code></a>
until there is data to be checked; the digest can then be extracted
using <a class="link" href="glib-Data-Checksums.html#g-checksum-get-string"><code class="function">g_checksum_get_string()</code></a>, which will return the checksum as a
hexadecimal string; or <a class="link" href="glib-Data-Checksums.html#g-checksum-get-digest"><code class="function">g_checksum_get_digest()</code></a>, which will return a
vector of raw bytes. Once either <a class="link" href="glib-Data-Checksums.html#g-checksum-get-string"><code class="function">g_checksum_get_string()</code></a> or
<a class="link" href="glib-Data-Checksums.html#g-checksum-get-digest"><code class="function">g_checksum_get_digest()</code></a> have been called on a <a class="link" href="glib-Data-Checksums.html#GChecksum"><span class="type">GChecksum</span></a>, the checksum
will be closed and it won't be possible to call <a class="link" href="glib-Data-Checksums.html#g-checksum-update"><code class="function">g_checksum_update()</code></a>
on it anymore.</p>
<p>

</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>checksum_type</code></em>&#160;:</span></p></td>
<td> the desired type of checksum
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></p></td>
<td> the newly created <a class="link" href="glib-Data-Checksums.html#GChecksum"><span class="type">GChecksum</span></a>, or <a class="link" href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>. 
  Use <a class="link" href="glib-Data-Checksums.html#g-checksum-free"><code class="function">g_checksum_free()</code></a> to free the memory allocated by it.

</td>
</tr>
</tbody>
</table></div>
<p class="since">Since  2.16
</p>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id3085118"></a><h3>
<a name="g-checksum-copy"></a>g_checksum_copy ()</h3>
<a class="indexterm" name="id3085133"></a><pre class="programlisting"><a class="link" href="glib-Data-Checksums.html#GChecksum">GChecksum</a>*          g_checksum_copy                     (const <a class="link" href="glib-Data-Checksums.html#GChecksum">GChecksum</a> *checksum);</pre>
<p>
Copies a <a class="link" href="glib-Data-Checksums.html#GChecksum"><span class="type">GChecksum</span></a>. If <em class="parameter"><code>checksum</code></em> has been closed, by calling
<a class="link" href="glib-Data-Checksums.html#g-checksum-get-string"><code class="function">g_checksum_get_string()</code></a> or <a class="link" href="glib-Data-Checksums.html#g-checksum-get-digest"><code class="function">g_checksum_get_digest()</code></a>, the copied
checksum will be closed as well.</p>
<p>

</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>checksum</code></em>&#160;:</span></p></td>
<td> the <a class="link" href="glib-Data-Checksums.html#GChecksum"><span class="type">GChecksum</span></a> to copy
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></p></td>
<td> the copy of the passed <a class="link" href="glib-Data-Checksums.html#GChecksum"><span class="type">GChecksum</span></a>. Use <a class="link" href="glib-Data-Checksums.html#g-checksum-free"><code class="function">g_checksum_free()</code></a>
  when finished using it.

</td>
</tr>
</tbody>
</table></div>
<p class="since">Since  2.16
</p>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id3085265"></a><h3>
<a name="g-checksum-free"></a>g_checksum_free ()</h3>
<a class="indexterm" name="id3085280"></a><pre class="programlisting">void                g_checksum_free                     (<a class="link" href="glib-Data-Checksums.html#GChecksum">GChecksum</a> *checksum);</pre>
<p>
Frees the memory allocated for <em class="parameter"><code>checksum</code></em>.</p>
<p>

</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code>checksum</code></em>&#160;:</span></p></td>
<td> a <a class="link" href="glib-Data-Checksums.html#GChecksum"><span class="type">GChecksum</span></a>
</td>
</tr></tbody>
</table></div>
<p class="since">Since  2.16
</p>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id3085351"></a><h3>
<a name="g-checksum-update"></a>g_checksum_update ()</h3>
<a class="indexterm" name="id3085367"></a><pre class="programlisting">void                g_checksum_update                   (<a class="link" href="glib-Data-Checksums.html#GChecksum">GChecksum</a> *checksum,
                                                         const <a class="link" href="glib-Basic-Types.html#guchar">guchar</a> *data,
                                                         <a class="link" href="glib-Basic-Types.html#gssize">gssize</a> length);</pre>
<p>
Feeds <em class="parameter"><code>data</code></em> into an existing <a class="link" href="glib-Data-Checksums.html#GChecksum"><span class="type">GChecksum</span></a>. The checksum must still be
open, that is <a class="link" href="glib-Data-Checksums.html#g-checksum-get-string"><code class="function">g_checksum_get_string()</code></a> or <a class="link" href="glib-Data-Checksums.html#g-checksum-get-digest"><code class="function">g_checksum_get_digest()</code></a> must
not have been called on <em class="parameter"><code>checksum</code></em>.</p>
<p>

</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>checksum</code></em>&#160;:</span></p></td>
<td> a <a class="link" href="glib-Data-Checksums.html#GChecksum"><span class="type">GChecksum</span></a>
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>data</code></em>&#160;:</span></p></td>
<td> buffer used to compute the checksum
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>length</code></em>&#160;:</span></p></td>
<td> size of the buffer, or -1 if it is a null-terminated string.
</td>
</tr>
</tbody>
</table></div>
<p class="since">Since  2.16
</p>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id3085518"></a><h3>
<a name="g-checksum-get-string"></a>g_checksum_get_string ()</h3>
<a class="indexterm" name="id3085534"></a><pre class="programlisting">const <a class="link" href="glib-Basic-Types.html#gchar">gchar</a>*        g_checksum_get_string               (<a class="link" href="glib-Data-Checksums.html#GChecksum">GChecksum</a> *checksum);</pre>
<p>
Gets the digest as an hexadecimal string.
</p>
<p>
Once this function has been called the <a class="link" href="glib-Data-Checksums.html#GChecksum"><span class="type">GChecksum</span></a> can no longer be
updated with <a class="link" href="glib-Data-Checksums.html#g-checksum-update"><code class="function">g_checksum_update()</code></a>.</p>
<p>

</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>checksum</code></em>&#160;:</span></p></td>
<td> a <a class="link" href="glib-Data-Checksums.html#GChecksum"><span class="type">GChecksum</span></a>
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></p></td>
<td> the hexadecimal representation of the checksum. The
  returned string is owned by the checksum and should not be modified
  or freed.

</td>
</tr>
</tbody>
</table></div>
<p class="since">Since  2.16
</p>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id3085635"></a><h3>
<a name="g-checksum-get-digest"></a>g_checksum_get_digest ()</h3>
<a class="indexterm" name="id3085651"></a><pre class="programlisting">void                g_checksum_get_digest               (<a class="link" href="glib-Data-Checksums.html#GChecksum">GChecksum</a> *checksum,
                                                         <a class="link" href="glib-Basic-Types.html#guint8">guint8</a> *buffer,
                                                         <a class="link" href="glib-Basic-Types.html#gsize">gsize</a> *digest_len);</pre>
<p>
Gets the digest from <em class="parameter"><code>checksum</code></em> as a raw binary vector and places it
into <em class="parameter"><code>buffer</code></em>. The size of the digest depends on the type of checksum.
</p>
<p>
Once this function has been called, the <a class="link" href="glib-Data-Checksums.html#GChecksum"><span class="type">GChecksum</span></a> is closed and can
no longer be updated with <a class="link" href="glib-Data-Checksums.html#g-checksum-update"><code class="function">g_checksum_update()</code></a>.</p>
<p>

</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>checksum</code></em>&#160;:</span></p></td>
<td> a <a class="link" href="glib-Data-Checksums.html#GChecksum"><span class="type">GChecksum</span></a>
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>buffer</code></em>&#160;:</span></p></td>
<td> output buffer
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>digest_len</code></em>&#160;:</span></p></td>
<td> an inout parameter. The caller initializes it to the size of <em class="parameter"><code>buffer</code></em>.
  After the call it contains the length of the digest.
</td>
</tr>
</tbody>
</table></div>
<p class="since">Since  2.16
</p>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id3085803"></a><h3>
<a name="g-compute-checksum-for-data"></a>g_compute_checksum_for_data ()</h3>
<a class="indexterm" name="id3085819"></a><pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gchar">gchar</a>*              g_compute_checksum_for_data         (<a class="link" href="glib-Data-Checksums.html#GChecksumType">GChecksumType</a> checksum_type,
                                                         const <a class="link" href="glib-Basic-Types.html#guchar">guchar</a> *data,
                                                         <a class="link" href="glib-Basic-Types.html#gsize">gsize</a> length);</pre>
<p>
Computes the checksum for a binary <em class="parameter"><code>data</code></em> of <em class="parameter"><code>length</code></em>. This is a
convenience wrapper for <a class="link" href="glib-Data-Checksums.html#g-checksum-new"><code class="function">g_checksum_new()</code></a>, <a class="link" href="glib-Data-Checksums.html#g-checksum-get-string"><code class="function">g_checksum_get_string()</code></a>
and <a class="link" href="glib-Data-Checksums.html#g-checksum-free"><code class="function">g_checksum_free()</code></a>.</p>
<p>

</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>checksum_type</code></em>&#160;:</span></p></td>
<td> a <a class="link" href="glib-Data-Checksums.html#GChecksumType"><span class="type">GChecksumType</span></a>
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>data</code></em>&#160;:</span></p></td>
<td> binary blob to compute the digest of
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>length</code></em>&#160;:</span></p></td>
<td> length of <em class="parameter"><code>data</code></em>
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></p></td>
<td> the digest of the binary data as a string in hexadecimal.
  The returned string should be freed with <a class="link" href="glib-Memory-Allocation.html#g-free"><code class="function">g_free()</code></a> when done using it.

</td>
</tr>
</tbody>
</table></div>
<p class="since">Since  2.16
</p>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id3086001"></a><h3>
<a name="g-compute-checksum-for-string"></a>g_compute_checksum_for_string ()</h3>
<a class="indexterm" name="id3086017"></a><pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gchar">gchar</a>*              g_compute_checksum_for_string       (<a class="link" href="glib-Data-Checksums.html#GChecksumType">GChecksumType</a> checksum_type,
                                                         const <a class="link" href="glib-Basic-Types.html#gchar">gchar</a> *str,
                                                         <a class="link" href="glib-Basic-Types.html#gssize">gssize</a> length);</pre>
<p>
Computes the checksum of a string.</p>
<p>

</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>checksum_type</code></em>&#160;:</span></p></td>
<td> a <a class="link" href="glib-Data-Checksums.html#GChecksumType"><span class="type">GChecksumType</span></a>
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>str</code></em>&#160;:</span></p></td>
<td> the string to compute the checksum of
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>length</code></em>&#160;:</span></p></td>
<td> the length of the string, or -1 if the string is null-terminated.
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></p></td>
<td> the checksum as a hexadecimal string. The returned string
  should be freed with <a class="link" href="glib-Memory-Allocation.html#g-free"><code class="function">g_free()</code></a> when done using it.

</td>
</tr>
</tbody>
</table></div>
<p class="since">Since  2.16
</p>
</div>
</div>
<div class="refsect1" lang="en">
<a name="id3086151"></a><div class="refsect2" lang="en"><a name="id3086152"></a></div>
<hr>
<div class="refsect2" lang="en"><a name="id3086153"></a></div>
</div>
</div>
</body>
</html>
